﻿<%@ Page Title="" EnableEventValidation="false" Language="C#" MasterPageFile="~/Admin.master"
    AutoEventWireup="true" CodeFile="AdminPermission.aspx.cs" Inherits="AdminPermission" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <script type="text/javascript">

        function SetChangeValue(objHidden) {
            objHidden.value = "true";
        }

        function SelectAll(id) {
            //get reference of GridView control
            var grid = document.getElementById("<%= gvAdminPermission.ClientID %>");
            //variable to contain the cell of the grid
            var cell;

            if (grid.rows.length > 0) {
                //loop starts from 1. rows[0] points to the header.
                for (i = 1; i < grid.rows.length; i++) {
                    //get the reference of first column
                    cell = grid.rows[i].cells[0];

                    //loop according to the number of childNodes in the cell
                    for (j = 0; j < cell.childNodes.length; j++) {
                        //if childNode type is CheckBox                 
                        if (cell.childNodes[j].type == "checkbox") {
                            //assign the status of the Select All checkbox to the cell checkbox within the grid
                            cell.childNodes[j].checked = document.getElementById(id).checked;
                        }
                    }
                }
            }
        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="box-border">
        <table cellpadding="0" cellspacing="0" style="width: 100%; border: 0;">
            <tr>
                <td>
                    <asp:GridView BorderStyle="None" GridLines="Horizontal" ID="AdminTypesView" runat="server"
                        AutoGenerateColumns="False" DataSourceID="SqlDataSource1" DataKeyNames="UserTypeId"
                        AutoGenerateSelectButton="true" 
                        onselectedindexchanged="AdminTypesView_SelectedIndexChanged2" 
                        onselectedindexchanging="AdminTypesView_SelectedIndexChanging">
                        <Columns>
                            <asp:TemplateField HeaderText="S.No">
                                <ItemTemplate>
                                    <asp:Label ID="lblId" runat="server" Text=' <%# Container.DataItemIndex + 1 %>' />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="UserType" HeaderText="Admin Type" />
                        </Columns>
                        <EmptyDataTemplate>
                            No Data Found
                        </EmptyDataTemplate>
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                        SelectCommand="select * from tblUserType"></asp:SqlDataSource>
                </td>
                <td>
                    <asp:Panel ID="Panel1" runat="server" Visible="true">
                        <div>
                            <br />
                            <br />
                            <br />
                            <asp:HiddenField ID="hdUserId" runat="server" Value="" />
                            <asp:GridView BorderStyle="None" GridLines="Horizontal" ID="gvAdminPermission" runat="server"
                                AutoGenerateColumns="False" DataSourceID="SqlDataSource2" AllowPaging="true" PageSize="100"
                                AllowSorting="true" OnPageIndexChanging="gvAdminPermission_PageIndexChanging">
                                <Columns>
                                    <asp:TemplateField HeaderText="S.No">
                                        <ItemTemplate>
                                            <asp:Label ID="lblId" runat="server" Text=' <%# Container.DataItemIndex + 1 %>' />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField>
                                        <HeaderTemplate>
                                            Rights
                                        </HeaderTemplate>
                                        <ItemTemplate>
                                            <asp:HiddenField ID="HddPageID" runat="server" Value='<%# Eval("PageId") %>' />
                                            <asp:CheckBox ID="ChkAll" Checked='<%# Convert.ToBoolean(DataBinder.Eval (Container.DataItem, "IsExists") )%>'
                                                runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="PageName" HeaderText="Page Title" SortExpression="PageName" />
                                </Columns>
                                <EmptyDataTemplate>
                                    No Data Found
                                </EmptyDataTemplate>
                            </asp:GridView>
                            <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
                                SelectCommand="GetAllPagesForRights" SelectCommandType="StoredProcedure">
                                <SelectParameters>
                                    <asp:ControlParameter ControlID="AdminTypesView" DefaultValue="0" Name="UserType"
                                        PropertyName="SelectedValue" Type="Int32" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                        </div>
                        <br />
                        <br />
                        <div>
                            <asp:Button ID="btnSave" runat="server" Text="Save" Width="53px" OnClick="btnSave_Click" />
                        </div>
                    </asp:Panel>
                </td>
            </tr>
        </table>
        <br style="clear: both;" />
        <br />
        <%--<asp:Panel ID="Panel2" runat="server" Visible="false">
    <asp:TextBox ID="TxtPageTitle" runat="server"></asp:TextBox> <br />
    <asp:TextBox ID="TxtPageId" runat="server"></asp:TextBox><br />
    <asp:CheckBox ID="ChkAdd" runat="server" />
    <asp:CheckBox ID="ChkEdit" runat="server" />
    <asp:CheckBox ID="ChkDel" runat="server" /> <br />
    <asp:Button ID="BtnRecord" runat="server" Text="Add Record"  OnClick="BtnRecord_Click"/>
    </asp:Panel>--%>
</asp:Content>
